package com.yupi.yuaicodemother.service;

import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.yupi.yuaicodemother.common.DeleteRequest;
import com.yupi.yuaicodemother.model.dto.app.AppQueryRequest;
import com.yupi.yuaicodemother.model.dto.app.AppUpdateRequest;
import com.yupi.yuaicodemother.model.dto.app.AppAddRequest;
import com.yupi.yuaicodemother.model.entity.App;
import com.yupi.yuaicodemother.model.entity.User;
import com.yupi.yuaicodemother.model.vo.AppVO;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 * 应用 服务层。
 *
 */
public interface AppService extends IService<App> {

    /**
     * 创建应用
     * @return appId
     */
    Long crateApp(AppAddRequest appAddRequest, User loginUser);


    /**
     * 更新 app
     */
    void updateApp(AppUpdateRequest appUpdateRequest, User loginUser);


    /**
     * 删除 app
     */
    void deleteApp(DeleteRequest deleteRequest, User loginUser);

    /**
     * 脱敏 app 信息
     */
    AppVO getAppVO(App app);

    /**
     * 获取查询条件
     */
    QueryWrapper getQueryWrapper(AppQueryRequest appQueryRequest);

    /**
     * 获取 app 脱敏信息列表
     */
    List<AppVO> getAppVOList(List<App> appList);

    /**
     * 通过对话生成代码
     * @param message 用户提示词
     * @return 流式结果
     */
    Flux<String> chatToGenCode(Long appId, String message, User loginUser);

    /**
     * 应用部署接口
     */
    String deployApp(Long AppId, User loginUser);


    /**
     * 异步生成应用截图并更新封面
     *
     * @param appId  应用ID
     * @param appUrl 应用访问URL
     */
    void generateAppScreenshotAsync(Long appId, String appUrl);
}
